﻿Imports Runa.Core.Extension
Imports Runa.Core.ResourceManager
Imports Runa.Core.Runtime
Imports Runa.Core.Input

Public MustInherit Class UIElementBase
    Inherits GameComponent
    Implements IDrawable

    Private m_DrawOrder As Integer
    Private m_Visible As Boolean

    Public Property Name() As String
    Public Property Location() As New Vector2
    Public Property Size() As New Vector2
    Public Property Anchor() As New Point
    Public Property SpriteBach() As SpriteBatch

    Public ReadOnly Property DrawOrder As Integer Implements IDrawable.DrawOrder
        Get
            Return Me.m_DrawOrder
        End Get
    End Property

    Public ReadOnly Property Visible As Boolean Implements IDrawable.Visible
        Get
            Return Me.m_Visible
        End Get
    End Property

    Public Event InputBegin(ByVal sender As Object, ByVal e As InputEventArgs)
    Public Event InputEnd(ByVal sender As Object, ByVal e As InputEventArgs)
    Public Event DrawOrderChanged(sender As Object, e As System.EventArgs) Implements IDrawable.DrawOrderChanged
    Public Event VisibleChanged(sender As Object, e As System.EventArgs) Implements IDrawable.VisibleChanged

    Public Sub New(ByVal g As Game, Optional ByVal sb As SpriteBatch = Nothing)
        MyBase.New(g)
        Me.Name = Me.GetType().Assembly.FullName.RightOfLastChar(".")
        If sb Is Nothing Then
            Me.SpriteBach = New SpriteBatch(g.GraphicsDevice)
        Else
            Me.SpriteBach = sb
        End If
    End Sub

    Public Sub New(ByVal name As String, ByVal g As Game, Optional ByVal sb As SpriteBatch = Nothing)
        MyBase.New(g)
        Me.Name = name
        If sb Is Nothing Then
            Me.SpriteBach = New SpriteBatch(g.GraphicsDevice)
        Else
            Me.SpriteBach = sb
        End If
    End Sub

    Public Sub New(ByVal name As String, ByVal drawOrder As Integer, ByVal g As Game, Optional ByVal sb As SpriteBatch = Nothing)
        MyBase.New(g)
        Me.Name = name
        If sb Is Nothing Then
            Me.SpriteBach = New SpriteBatch(g.GraphicsDevice)
        Else
            Me.SpriteBach = sb
        End If
        Me.m_DrawOrder = drawOrder
    End Sub

    Public MustOverride Sub Draw(gameTime As GameTime) Implements Microsoft.Xna.Framework.IDrawable.Draw

    Public Overrides Sub Update(gameTime As Microsoft.Xna.Framework.GameTime)

        MyBase.Update(gameTime)
    End Sub

End Class